<html>
<head><meta charset="utf-8"><title>existential types · general · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/index.html">general</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/existential.20types.html">existential types</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="164352977"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/existential%20types/near/164352977" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/existential.20types.html#164352977">(Apr 27 2019 at 20:48)</a>:</h4>
<p>What's the one-sentence primary reason for why we can't stabilize  existential types today? I'm giving an overview of compiler stuff coming "soon" and want to give a high-level reason why certain things aren't there yet.</p>



<a name="164353300"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/existential%20types/near/164353300" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/existential.20types.html#164353300">(Apr 27 2019 at 20:57)</a>:</h4>
<p>Needs syntax agreement.</p>



<a name="164353355"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/existential%20types/near/164353355" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/existential.20types.html#164353355">(Apr 27 2019 at 20:58)</a>:</h4>
<p>Maybe <span class="user-mention" data-user-id="124288">@oli</span> knows if there are implementation bugs that are blocking as well</p>



<a name="164357010"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/existential%20types/near/164357010" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/existential.20types.html#164357010">(Apr 27 2019 at 22:43)</a>:</h4>
<p>That seems encouraging!</p>



<a name="164357012"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/existential%20types/near/164357012" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/existential.20types.html#164357012">(Apr 27 2019 at 22:44)</a>:</h4>
<p>I'm on board with the <code>type Foo = impl Bar</code> syntax personally, but I've spent zero time considering rationale. It just "feels" right</p>



<a name="164380090"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/existential%20types/near/164380090" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/existential.20types.html#164380090">(Apr 28 2019 at 10:15)</a>:</h4>
<p>there are some bugs, and loads of diagnostics that need improvement</p>



<a name="164537207"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/existential%20types/near/164537207" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/existential.20types.html#164537207">(Apr 30 2019 at 13:09)</a>:</h4>
<blockquote>
<p>I'm on board with the <code>type Foo = impl Bar</code> syntax personally, but I've spent zero time considering rationale. It just "feels" right</p>
</blockquote>
<p>It "feels" right but if we want <code>existential type Foo;</code> to be valid, there is no way to express this with the <code>impl Trait</code> syntax.</p>



<a name="164537695"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/existential%20types/near/164537695" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/existential.20types.html#164537695">(Apr 30 2019 at 13:16)</a>:</h4>
<p>There was just a PR forbidding <code>existential type Foo: 'static;</code> and telling you that you need a trait bound just like the diagnostic for <code>impl 'static</code></p>



<a name="164538311"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/existential%20types/near/164538311" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/existential.20types.html#164538311">(Apr 30 2019 at 13:24)</a>:</h4>
<p><code>impl 'static</code> could be valid if we wanted it to but it's a rather boring thing to say</p>



<a name="164538321"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/existential%20types/near/164538321" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/existential.20types.html#164538321">(Apr 30 2019 at 13:24)</a>:</h4>
<p>it's possibly useful in APIT</p>



<a name="164538334"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/existential%20types/near/164538334" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/existential.20types.html#164538334">(Apr 30 2019 at 13:25)</a>:</h4>
<p>APIT?</p>



<a name="164538348"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/existential%20types/near/164538348" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/existential.20types.html#164538348">(Apr 30 2019 at 13:25)</a>:</h4>
<p><span class="user-mention" data-user-id="216785">@Tim Diekmann</span>  <code>arg: impl Trait</code></p>



<a name="164538379"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/existential%20types/near/164538379" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/existential.20types.html#164538379">(Apr 30 2019 at 13:25)</a>:</h4>
<p><span class="user-mention" data-user-id="216785">@Tim Diekmann</span> blame varkor for the initialisms ;)</p>



<a name="164538386"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/existential%20types/near/164538386" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/existential.20types.html#164538386">(Apr 30 2019 at 13:25)</a>:</h4>
<p>I'll do :D</p>



<a name="164538526"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/existential%20types/near/164538526" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/existential.20types.html#164538526">(Apr 30 2019 at 13:27)</a>:</h4>
<p>However, I don't see, why we don't possibly want <code>existential type Foo;</code> without bound to be valid at some point (not necessarily now).</p>



<a name="164538599"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/existential%20types/near/164538599" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/existential.20types.html#164538599">(Apr 30 2019 at 13:28)</a>:</h4>
<p><span class="user-mention" data-user-id="216785">@Tim Diekmann</span>  it's also a rather boring thing to say; you cannot extract any info out of it</p>



<a name="164538606"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/existential%20types/near/164538606" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/existential.20types.html#164538606">(Apr 30 2019 at 13:28)</a>:</h4>
<p>it's like saying <code>impl Sized</code></p>



<a name="164538646"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/existential%20types/near/164538646" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/existential.20types.html#164538646">(Apr 30 2019 at 13:29)</a>:</h4>
<p><span class="user-mention" data-user-id="126931">@centril</span> It's useful for an opaque type returned by any function and to be passed to another function of the same interface</p>



<a name="164538673"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/existential%20types/near/164538673" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/existential.20types.html#164538673">(Apr 30 2019 at 13:30)</a>:</h4>
<p><span class="user-mention" data-user-id="216785">@Tim Diekmann</span> that's not possible right now. There's no way to reveal the opaque type</p>



<a name="164538748"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/existential%20types/near/164538748" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/existential.20types.html#164538748">(Apr 30 2019 at 13:30)</a>:</h4>
<p>but that's just an implementation detail I guess</p>



<a name="164538797"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/existential%20types/near/164538797" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/existential.20types.html#164538797">(Apr 30 2019 at 13:31)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span> it seems to me that the very essence of an opaque type is that you cannot reveal it :D</p>



<a name="164538812"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/existential%20types/near/164538812" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/existential.20types.html#164538812">(Apr 30 2019 at 13:31)</a>:</h4>
<p><span class="user-mention" data-user-id="216785">@Tim Diekmann</span> if you truly want to do that, just use <code>existential type Foo: Sized;</code></p>



<a name="164538819"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/existential%20types/near/164538819" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/existential.20types.html#164538819">(Apr 30 2019 at 13:31)</a>:</h4>
<p>the RFC thinks otherwise</p>



<a name="164538835"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/existential%20types/near/164538835" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/existential.20types.html#164538835">(Apr 30 2019 at 13:31)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span> hmm, reveal in the same module?</p>



<a name="164538838"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/existential%20types/near/164538838" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/existential.20types.html#164538838">(Apr 30 2019 at 13:31)</a>:</h4>
<p>jop</p>



<a name="164538849"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/existential%20types/near/164538849" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/existential.20types.html#164538849">(Apr 30 2019 at 13:32)</a>:</h4>
<p>oh yeah, that's true</p>



<a name="164538900"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/existential%20types/near/164538900" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/existential.20types.html#164538900">(Apr 30 2019 at 13:32)</a>:</h4>
<p>"opaque" has a scope</p>



<a name="164538914"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/existential%20types/near/164538914" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/existential.20types.html#164538914">(Apr 30 2019 at 13:32)</a>:</h4>
<p>I mean I personally would prefer all reveals to have to go through an explicit function</p>



<a name="164538938"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/existential%20types/near/164538938" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/existential.20types.html#164538938">(Apr 30 2019 at 13:33)</a>:</h4>
<p>just to make it clear where the users actually wants to reveal sth</p>



<a name="164538947"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/existential%20types/near/164538947" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/existential.20types.html#164538947">(Apr 30 2019 at 13:33)</a>:</h4>
<p>To make this code work?</p>
<div class="codehilite"><pre><span></span>mod public_api {
    pub existential type Foo: Sized;

    pub fn give_type() -&gt; Foo {
        return 10_u32;
    }
    pub fn take_type(f: Foo) {
        println!(&quot;{}&quot;,f)
    }
}
</pre></div>


<p><a href="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=8f4579857e021e208e14713480d1602d" target="_blank" title="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=8f4579857e021e208e14713480d1602d">Playground</a></p>



<a name="164538974"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/existential%20types/near/164538974" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/existential.20types.html#164538974">(Apr 30 2019 at 13:33)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span> I'd just make it work inside the whole module</p>



<a name="164538985"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/existential%20types/near/164538985" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/existential.20types.html#164538985">(Apr 30 2019 at 13:33)</a>:</h4>
<p>and allow partially defining uses</p>



<a name="164538987"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/existential%20types/near/164538987" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/existential.20types.html#164538987">(Apr 30 2019 at 13:33)</a>:</h4>
<blockquote>
<p><span class="user-mention silent" data-user-id="216785">Tim Diekmann</span> if you truly want to do that, just use <code>existential type Foo: Sized;</code></p>
</blockquote>
<p>Heh, good point</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>